package org.vnl.platform.web.impl.myfaces.dojo.component.tag;

import javax.el.MethodExpression;


import javax.el.ValueExpression;
import javax.faces.component.UIComponent;

import org.apache.commons.lang3.StringUtils;
import org.vnl.platform.web.impl.myfaces.dojo.IDojoConstants;
import org.vnl.platform.web.impl.myfaces.dojo.component.DojoButton;


public class DojoButtonTag extends DojoTag {

    private MethodExpression action;
    private ValueExpression value;
    
    @Override
    public String getComponentType() {
        return IDojoConstants.COMPONENT_BUTTON_TYPE;
    }

    @Override
    public String getRendererType() {
        return IDojoConstants.COMPONENT_BUTTON_TYPE;
    }

    @Override
    protected void setProperties(UIComponent arg0) {
        super.setProperties(arg0);
        if (arg0 instanceof DojoButton) {
            String dojoId = getDojoIdValue();
            if (!StringUtils.isBlank(dojoId)) {
                ((DojoButton) arg0).setDojoId(dojoId);
            }
            if (action != null) {
                ((DojoButton) arg0).setActionExpression(action);
            }
            if (value != null) {
                ((DojoButton) arg0).setValueExpression("value", value);
                ((DojoButton) arg0).setValueExpression("valueaaa", value);
            }
        }
    }

    public MethodExpression getAction() {
        return action;
    }

    public void setAction(MethodExpression action) {
        this.action = action;
    }

    public ValueExpression getValue() {
        return value;
    }

    public void setValue(ValueExpression value) {
        this.value = value;
    }

}
